<template>
	<om-page :title="pageTitle">
		<om-formpage :searchMaxLength="10" @confirm="searchClick" :datas="commonData.datas" :userid="userId">
			<template slot="header">
				<p>已加载 {{ commonData.datas.length }} 条数据</p>
			</template>
		</om-formpage>
		<uni-fab horizontal="right" @trigger="trigger" direction="vertical" :content="buttons" :scrollTop="scrollTop" />
		<tui-loadmore :visible="commonData.loadding"></tui-loadmore>
		<tui-nomore :visible="!commonData.pullUpOn"></tui-nomore>
	</om-page>
</template>

<script>
	import { mapState } from 'pinia';
	import {useLoginUserStore} from '@/stores/login-user.js';
	import listLoad from '../../../static/js/listLoad.js';
	import { debounce } from '../../../static/js/common.js'
	const app = getApp();
	export default {
		data() {
			return {
				commonData: {
					datas: [],
					query: {

					}
				},
				datas: [],
				searchStr: '',
				total: 0,
				page: 0,
				scrollTop: 0,
				loadding: false,
				pullUpOn: true,
				buttons: [app.globalData.button.home],
				pageTitle: "参与表单"
			};
		},
		computed: mapState(useLoginUserStore, ['userId']),
		methods: {
			trigger(e) {
				if (e.item.text === '返回首页') {
					uni.switchTab({
						url: '/pages/main/main/main'
					});
				} else if (e.item.text === '返回顶部') {
					this.scrollTop = 0;
					uni.pageScrollTo({
						scrollTop: 0
					});
				}
			},
			searchClick:function(e){
				let _that = this;
				_that.commonData.query.searchStr = e.value;
					listLoad.initData(_that, 'wxCommon/getLaunches')
				},
			inputSearch:function(e){
				let _that = this;
				_that.commonData.query.searchStr = e.value;
				listLoad.initData(_that, 'wxCommon/getLaunches')
				},
		},
		
		onLoad: function(options) {
			this.pageTitle = (options.title || '') + '参与表单'
			uni.setNavigationBarTitle({
				title: this.pageTitle
			});
			listLoad.initData(this, 'wxCommon/getLaunches');
		},
		onPageScroll(e) {
			let _that = this;
			_that.scrollTop = e.scrollTop;
			let buttons = _that.buttons;
			if (e.scrollTop > 5) {
				if (_that.buttons.length === 1) {
					buttons.unshift(app.globalData.button.top);
					_that.buttons = buttons;
				}
			} else {
				if (_that.buttons.length === 2) {
					buttons.shift();
					_that.buttons = buttons;
				}
			}
		},
		//页面相关事件处理函数--监听用户下拉动作
		onPullDownRefresh: function() {
			listLoad.pullDownRefresh(this);
		},

		// 页面上拉触底事件的处理函数
		onReachBottom: function() {
			listLoad.reachBottom(this);
		}
	};
</script>

<style></style>
